package cn.znzz.cjm.mapper;

import cn.znzz.cjm.domain.LoginUser;
import cn.znzz.cjm.domain.Permission;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author chenjiangmin
 * @since 2021-12-16
 */
public interface LoginUserMapper extends BaseMapper<LoginUser> {
    @Select("SELECT\n" +
            "\tt5.*\n" +
            "FROM\n" +
            "\tt_user_role t2\n" +
            "LEFT JOIN t_role_permission t4 ON t2.role_id = t4.role_id\n" +
            "LEFT JOIN t_permission t5 ON t4.permission_id = t5.id\n" +
            "WHERE\n" +
            "\tt2.user_id = #{id}")
    List<Permission> findPermissionsByUserId(Long id);
}
